package com.yusys.pattern.regular.oecm;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

public class BookStore {
    //注意这里list中保存的是接口
    private  static final List<IBook> bookList = new ArrayList<IBook>();

    //static静态模块初始化数据，实际项目中一般是由持久层完成
    static {
        bookList.add(new NovelBook("天龙八部",3200,"金庸"));
        bookList.add(new NovelBook("巴黎圣母院",5600,"雨果"));
        bookList.add(new NovelBook("悲惨世界",3500,"雨果"));
        bookList.add(new NovelBook("金瓶梅",4300,"兰陵笑笑生"));
    }

    public static void main(String[] args) {
        NumberFormat format = NumberFormat.getCurrencyInstance();
        format.setMaximumFractionDigits(2);//精确位数

        for (int i = 0; i < bookList.size(); i++) {
            System.out.println("name:"+bookList.get(i).getName()+"\tauthor:"+bookList.get(i).getAuthor()+"\tprice:"
                    +format.format(bookList.get(i).getPrice()/100.0));
        }
    }
}
